#include<bits/stdc++.h>
using namespace std;
const int M=1e6+5;
int f[M],g[M],n,x,A,B;
int dep[M],fa[M];
vector<int> E[M],d[M],a1[M];
int dfn[M],rk[M],dfncnt,mxdep[M],R[M];
bool vis[M];
inline void dfs(int now,int f){
	dfn[now]=++dfncnt;
	rk[dfncnt]=now;
	fa[now]=f;
	d[dep[now]].push_back(now);
	mxdep[now]=dep[now];
	for(auto p:E[now])if(p^f){
		dep[p]=dep[now]+1;
		dfs(p,now);
		mxdep[now]=max(mxdep[now],mxdep[p]);
	}
	R[now]=dfncnt;
	return;
}
inline int DFS(int now,int ff,int de){
	if(de>B)return 0;
	int res=g[now];
	for(auto p:E[now])if(p^ff)res=max(res,DFS(p,now,de+1));
	return res;
}
int pre[M],suf[M],val[M];
bool flg[M];
inline int conv(int x){
	int tp=max(pre[x],suf[x]);
	if(flg[fa[x]])tp=min(pre[x],suf[x]);
	if(tp==0)return fa[x];
	return tp;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	freopen("nim.in","r",stdin);
	freopen("nim.out","w",stdout);
	cin>>n>>x>>A>>B;
	if(A<=B)return cout<<1<<"\n",0;
	for(int i=1;i<=n;i++)f[i]=1e9;
	for(int i=1,u,v;i<n;i++)cin>>u>>v,E[u].push_back(v),E[v].push_back(u);
	dfs(x,0);
	for(int i=1;i<=n;i++){
		int now=i;
		for(int j=1;j<A;j++)now=fa[now];
		a1[now].push_back(i);
	}
	for(int i=n,j=n+B;i>=0;i--,j--){
		for(auto u:d[i]){
			int lstpo=0;
			if(mxdep[u]-dep[u]<A){
				flg[u]=1;
				g[u]=u;
				pre[0]=u;
				for(auto p:E[u])if(p^fa[u]){
					val[p]=1e9;
					for(int j=dfn[p];j<=R[p];j++)if(dep[rk[j]]-dep[p]<B)val[p]=min(val[p],rk[j]);
					g[u]=min(g[u],val[p]);
					pre[p]=min(pre[lstpo],val[lstpo]);
					lstpo=p;
				}
				pre[0]=0;
				reverse(E[u].begin(),E[u].end());
				lstpo=0;
				suf[0]=1e9;
				for(auto p:E[u])if(p^fa[u]){
					suf[p]=min(suf[lstpo],val[lstpo]);
					lstpo=p;
				}
				suf[0]=0;
			}else{
				for(auto p:E[u])if(p^fa[u]){
					for(auto nx:a1[p])val[p]=max(val[p],f[nx]);
					g[u]=max(g[u],val[p]);
					pre[p]=max(pre[lstpo],val[lstpo]);
					lstpo=p;
				}
				reverse(E[u].begin(),E[u].end());
				lstpo=0;
				for(auto p:E[u])if(p^fa[u]){
					suf[p]=max(suf[lstpo],val[lstpo]);
					lstpo=p;
				}
			}
			// cerr<<u<<" "<<g[u]<<" "<<mxdep[u]<<" "<<dep[u]<<"\n";
		}
		for(auto u:d[j]){
			memset(vis,0,sizeof vis);
			int now=u;
			for(int i=1;i<=B;i++)f[u]=min(f[u],conv(now)),vis[now]=1,now=fa[now];
			f[u]=min(f[u],DFS(u,0,1));
			cerr<<u<<" "<<f[u]<<"\n";
		}
	}
	cout<<g[x]<<"\n";
	return 0;
}